<template>
	<sw-common-frame :count="dataCount" :loading="loading">
		<template slot="button">
			<el-button size="small" type="primary" icon="el-icon-plus" @click="handleOpenDialog()">新增</el-button>
			<el-divider direction="vertical"></el-divider>
			<el-radio-group size="small" v-model="activeName" v-removeAriaHidden>
				<el-radio-button label="1">前台栏目</el-radio-button>
				<el-radio-button label="2">一级栏目</el-radio-button>
				<el-radio-button label="3">二级栏目</el-radio-button>
			</el-radio-group>
		</template>
		<el-form slot="query" size="small" inline>
			<el-form-item>
				<el-input v-model="queryData.name" clearable placeholder="栏目名称" style="width: 180px"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" icon="el-icon-search" @click="queryTableData()">查询</el-button>
			</el-form-item>
		</el-form>
		<el-table slot="table" size="medium" :data="tableData" stripe height="100%">
			<el-table-column type="index" align="center" width="50" label="序号" />
			<el-table-column label="栏目名称" prop="name" min-width="120"></el-table-column>
			<el-table-column label="栏目编码" prop="code" min-width="120"></el-table-column>
			<template v-if="activeName === '1'">
				<el-table-column label="英文名称" prop="field4" min-width="200" />
				<el-table-column label="二级标题" prop="field1" min-width="200" />
			</template>
			<el-table-column label="栏目状态" min-width="100">
				<template slot-scope="{ row }">
					<el-tag size="small" type="warning" disable-transitions v-if="row.isShow === '0'">显示</el-tag>
					<el-tag size="small" type="danger" disable-transitions v-if="row.isShow === '1'">隐藏</el-tag>
				</template>
			</el-table-column>
			<el-table-column label="创建时间" prop="createTime" min-width="160"></el-table-column>
			<el-table-column label="操作" width="132">
				<el-button-group slot-scope="{ row }">
					<el-button size="mini" type="warning" @click="handleOpenDialog(row.id)">修改</el-button>
					<el-button size="mini" type="danger" @click="handleDeleteData(row)">删除</el-button>
				</el-button-group>
			</el-table-column>
		</el-table>
		<template slot="page">
			<sw-pagination :total="dataCount" :page.sync="queryData.page" :limit.sync="queryData.limit" @change="queryTableData()"></sw-pagination>
		</template>
		<form-dialog v-model="formDialog" :data-id="dataId" :type="activeName" @refresh="queryTableData()"></form-dialog>
	</sw-common-frame>
</template>

<script>
import formDialog from './form';
import { mapGetters } from 'vuex';
import listMixins from '@/mixins/listMixins';
import { getColumnControlList, deleteColumnControl } from '@/api/system/sysColumnControl';
export default {
	mixins: [listMixins],
	components: { formDialog },
	data() {
		return {
			formData: {},
			activeName: '1',
			pageName: '站点栏目'
		};
	},
	computed: {
		...mapGetters(['userInfo']),
		listFunction() {
			return eval(getColumnControlList);
		},
		deleteFunction() {
			return eval(deleteColumnControl);
		},
		requestParams() {
			return { ...this.queryData, type: this.activeName };
		}
	},
	watch: {
		activeName: {
			handler(val) {
				this.queryTableData();
			},
			immediate: true
		}
	},
	methods: {}
};
</script>

<style lang="scss" scoped>
.base_info_title {
	display: flex;
	align-items: center;
	.image {
		margin-right: 16px;
	}
	.text {
		display: flex;
		flex-direction: column;
	}
}
</style>
